import 'package:flutter/material.dart';
import 'package:canteen/constants.dart';

class CategoryWidget extends StatelessWidget {
  CategoryWidget(
      {required this.category,
      required this.active,
      required this.activeNum,
      this.onClick,
      this.longPress});

  final String category;
  final int active;
  final int activeNum;
  final void Function()? onClick;
  final void Function()? longPress;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onLongPress: longPress,
      onTap: onClick,
      child: AnimatedContainer(
        height: cWHeight,
        margin: EdgeInsets.only(left: activeNum == active ? 10 : 0),
        alignment: Alignment.center,
        decoration: BoxDecoration(
          border: activeNum == active
              ? Border.all(color: Colors.black.withOpacity(0.5), width: 2)
              : null,
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(18),
            bottomLeft: Radius.circular(18),
          ),
          // borderRadius: BorderRadius.only(
          //     topRight: Radius.circular(activeNum == active + 1 ? 8 : 0),
          //     bottomRight: Radius.circular(activeNum == active - 1 ? 8 : 0)),
        ),
        duration: Duration(milliseconds: 300),
        child: Text(
          category,
          style: TextStyle(
            fontSize:  activeNum == active ?14:12,
              color: category == '添加' ? Color(0xff2b3d85) : Colors.black),
        ),
      ),
    );
  }
}
